/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.composite.preference;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;

/**
 * Class defining preference constants for Composite Diagram elements
 */
public class CompositeDiagramPreferenceConstants {

	
	/** Preference constant for Port figure background color */
	public static final String P_PORT_BACKGROUNDCOLOR = "CompositeDiagramPreferenceConstants.Port.backGroundColor";
	
	/** Preference constant for Port figure border color */
	public static final String P_PORT_BORDERCOLOR = "CompositeDiagramPreferenceConstants.Port.borderColor";
	
	/** Preference constant for Port figure font color */
	public static final String P_PORT_FONTCOLOR = "CompositeDiagramPreferenceConstants.Port.fontColor";
	
	/** Preference constant for Port figure font */
	public static final String P_PORT_FONT = "CompositeDiagramPreferenceConstants.Port.font";
	
	
	/**
	 * Returns the RGB code from the specified store for the Port figure background color
	 * @param store the PreferenceStore where to load the preference
	 * @return the RGB code for the Port figure background color
	 */
	public static RGB getPreferencePortBackgroundColor(IPreferenceStore store) {
		return PreferenceConverter.getColor(store, P_PORT_BACKGROUNDCOLOR);
	}
	
	/**
	 * Returns the RGB code from the specified store for the Port figure border color
	 * @param store the PreferenceStore where to load the preference
	 * @return the RGB code for the Port figure border color
	 */
	public static RGB getPreferencePortBorderColor(IPreferenceStore store) {
		return PreferenceConverter.getColor(store, P_PORT_BORDERCOLOR);
	}
	
	/**
	 * Returns the RGB code from the specified store for the Port figure font color
	 * @param store the PreferenceStore where to load the preference
	 * @return the RGB code for the Port figure font color
	 */
	public static RGB getPreferencePortFontColor(IPreferenceStore store) {
		return PreferenceConverter.getColor(store, P_PORT_FONTCOLOR);
	}

	/**
	 * Returns the FontData from the specified store for the Port figure font
	 * @param store the PreferenceStore where to load the preference
	 * @return the FontData for the Port figure font
	 */
	public static FontData[] getPreferencePortFont(IPreferenceStore store) {
		return PreferenceConverter.getFontDataArray(store, P_PORT_FONT);
	}
	
	/**
	 * Set default preferences for the composite diagram elements in the specified preference store
	 * @param store the preference store where to specify the preferences
	 */
	public static void setDefaultPreferences(IPreferenceStore store) {
		// Port
		PreferenceConverter.setDefault(store, P_PORT_BACKGROUNDCOLOR, new RGB(227,221,239));
		PreferenceConverter.setDefault(store, P_PORT_BORDERCOLOR, new RGB(0,0,0));
		PreferenceConverter.setDefault(store, P_PORT_FONTCOLOR, new RGB(0,0,0));
		PreferenceConverter.setDefault(store, P_PORT_FONT, new FontData("Arial", 10, SWT.BOLD));	
	}
}
